# from flask import  Blueprint,request,redirect,abort
# bp = Blueprint('register_bp',__name__,url_prefix='/register')
# from blueprint.register_bp_impl import *
# from utils.decorator import *
#
# """
# 输入用户名、密码、手机号、邮箱。
# 首先进行非空判定，确认所有参数都是非空值。
# 创建验证码，发送到用户邮箱上，并且存储在缓存中，缓存的标识id为用户的邮箱。
# """
# @bp.route('/new')
# @json_response
# def addNewUser():
#     login_name = request.args.get('login_name', '')
#     password = request.args.get('password', '')
#     phone = request.args.get('phone', '')
#     mail = request.args.get('mail', '')
#     # 判断非空
#     if('' == login_name or '' == password or '' == phone or '' == mail):
#         return dict(success=False,msg='wrong input data.',code=100)
#     if(create_mail_auth_Code(login_name,password,phone,mail)):
#         return dict(success=True, data='OK')
#     else:
#         return dict(success=False, msg='create authorized code failed.',code=400)
# """
# 用户验证码进行验证。
# 首先进行非空判定，确认所有参数都是非空值。
# 判断输入的验证码与缓存中的是否相同。
# 成功则进行用户注册，失败则返回验证码过期或错误提示。
# """
# @bp.route('/verify_and_regist')
# def verify_Code():
#     login_name = request.args.get('login_name', '')
#     password = request.args.get('password', '')
#     phone = request.args.get('phone', '')
#     mail = request.args.get('mail', '')
#     auth_code = request.args.get('auth_code', '')
#     if ('' == login_name or '' == password or '' == phone or '' == mail or '' == auth_code):
#         return dict(success=False,msg='wrong input data.',code=100)
#     if verify_auth_Code(mail,auth_code):
#         if add_user(login_name,password,phone,mail):
#             return dict(success=True,data="添加用户成功")
#         else:
#             return dict(success=False,msg="添加用户失败，用户名或邮箱存在",code=600)
#     else:
#         return dict(success=False, msg="验证失败，验证码错误或已过期",code=500)
#
# """
# 开发找回密码的功能
# 使用邮箱找回。
# """
# @bp.route('/findPW')
# def findPW():
#     mail = request.args.get('mail', '')
#     if ('' == mail):
#         return dict(success=False,msg='wrong input data.',code=100)
#     if (create_findPW_auth_Code(mail)):
#         try:
#             user_data = find_user_data(mail)
#             return dict(success=True, data=user_data)
#         except Exception as err:
#             return dict(success=True, msg="查询不到该用户的信息",code=200)
#     else:
#         return dict(success=False, msg='create authorized code failed.',code=400)
# @bp.route('/resetPW')
# def resetPW():
#     mail = request.args.get('mail', '')
#     auth_code = request.args.get('auth_code', '')
#     password1 = request.args.get('password1', '')
#     password2 = request.args.get('password2', '')
#     if ('' == mail or '' == auth_code or '' == password1 or '' == password2):
#         return dict(success=False, msg='wrong input data.')
#     if(password1!=password2):
#         return dict(success=False, msg='reset password failed.',code=700)
#     if verify_findPW_auth_Code(mail,auth_code):
#         if reset_PW(mail,password1):
#             return dict(success=True, data='密码重设成功，请返回登陆.')
#         else:
#             return dict(success=False, msg='修改密码中出现错误.',code=800)
#     else:
#         return dict(success=False, msg='验证码错误或已过期',code=500)
